package controller.personal;

import java.sql.SQLException;
import java.util.ArrayList;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.multiaction.MultiActionController;

import personal.model.service.SearchPersonalService;
import personal.model.vo.AdminVO;
import personal.model.vo.DeptVO;
import personal.model.vo.EmpVO;
import personal.model.vo.GradeVO;

public class SearchPersonalController extends MultiActionController {
	private SearchPersonalService searchPersonalService;
	public void setSearchPersonalService(SearchPersonalService searchPersonalService){
		this.searchPersonalService = searchPersonalService;
	}
	public ModelAndView selectCode(HttpServletRequest request, HttpServletResponse response){
		return new ModelAndView("search/selectCode.personal");
	}
	public ModelAndView selectDeptCode(HttpServletRequest request, HttpServletResponse response
			, DeptVO deptVO){
		ArrayList<DeptVO> list=new ArrayList<DeptVO>();
		try {
			list=(ArrayList<DeptVO>)searchPersonalService.selectDeptCode();
		} catch (SQLException e) {
			System.out.println(e.getMessage());
		}
		return new ModelAndView("personalJSonView", "list", list);
	}
	public ModelAndView selectAdminCode(HttpServletRequest request, HttpServletResponse response
			, AdminVO adminVO){
		ArrayList<AdminVO> list=new ArrayList<AdminVO>();
		try {
			list=(ArrayList<AdminVO>)searchPersonalService.selectAdminCode();
		} catch (SQLException e) {
			System.out.println(e.getMessage());
		}
		return new ModelAndView("personalJSonView", "list", list);
	}
	public ModelAndView selectGradeCode(HttpServletRequest request, HttpServletResponse response
			, GradeVO gradeVO){
		ArrayList<GradeVO> list=new ArrayList<GradeVO>();
		try {
			list=(ArrayList<GradeVO>)searchPersonalService.selectGradeCode();
		} catch (SQLException e) {
			System.out.println(e.getMessage());
		}
		return new ModelAndView("personalJSonView", "list", list);
	}
	public ModelAndView selectPersonalCard(HttpServletRequest request, HttpServletResponse response){
		return new ModelAndView("search/selectPersonalCard.personal");
	}
	public ModelAndView selectPersonalCardResult(HttpServletRequest request
			, HttpServletResponse response){
		String selectMethod=request.getParameter("selectMethod");
		String selectValue=request.getParameter("selectValue");
		ArrayList<EmpVO> list=new ArrayList<EmpVO>();
		try {
			list=(ArrayList<EmpVO>)searchPersonalService.selectPersonalCardResult(selectMethod, selectValue);
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return new ModelAndView("personalJSonView", "list", list);
	}
}